package com.manlu.service;

import com.manlu.mapper.CategoryMapper;
import com.manlu.pojo.Category;
import com.manlu.vo.BaseResult;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Auther 漫路h
 * Created by 2020-05-14 16:04
 */
@Service
@Transactional
public class CategoryService {
    @Resource
    private CategoryMapper categoryMapper;


    /**
     * 根据分类级别查询分类
     * @param level 分类级别
     * @return
     */
    public BaseResult selectCategoryAllByLevel(String level) {
        //1.查询
        List<Category> categoryList = categoryMapper.selectCategoryAllByLevel(level);
        //2.返回
        return BaseResult.ok("ok",categoryList);
    }

    /**
     * 根据分类id查询分类
     * @param cid 分类id
     * @return
     */
    public BaseResult selectCategoryChildByCid(Integer cid) {
        //1.查询
        List<Category> categoryList = categoryMapper.selectCategoryListByCid(cid+"");
        //2.返回
        return BaseResult.ok("ok",categoryList);
    }
}
